/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
 * Nihongo
 * Copyright (C) Massimiliano Maniscalco 2011, 2012 <massi.neptune@yahoo.com>
 * 
 * Nihongo is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Nihongo is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef _TESTENGINE_H_
#define _TESTENGINE_H_
#include <gtkmm.h>
#include "parola.h"
#include "kanji.h"


using namespace std;

class TestEngine
{
public:
	inline ~TestEngine ();
	virtual void run_test ( char *options ) = 0;
	typedef sigc::signal<void> Type_signal_window_closed;
	inline Type_signal_window_closed signal_window_closed ( void ) { return window_closed; }
	typedef sigc::signal<void, Parola> Type_signal_parole;
	inline Type_signal_parole signal_parole_changed ( void ) { return commit_parole_changes; }
	typedef sigc::signal<void, Kanji> Type_signal_kanji;
	inline Type_signal_kanji signal_kanji_changed ( void ) { return commit_kanji_changes; }
	

protected:
	Glib::Rand *_random;
	Gtk::Window *_testWin;
	sigc::connection _testWinConnection;
	sigc::connection _timerConnection;
	int _timer;
	unsigned int _nrDom;
	char _modo;
	bool _verso;
	bool _paused;
	Type_signal_parole commit_parole_changes;
	Type_signal_kanji commit_kanji_changes;	
	Type_signal_window_closed window_closed;
	// toolbar
	Gtk::Label *_domandaNumLabel;
	Gtk::Label *_domandeTotLabel;
	Gtk::ToolButton *_skipToolButton;
	sigc::connection _skipToolConnection;
	Gtk::ToolButton *_pauseToolButton;
	sigc::connection _pauseToolConnection;
	Gtk::Label *_tempoLabel;
	// main
	Gtk::Label *_domandaLabel;	

	inline TestEngine ()
	{}
	void init_test_engine ( Glib::RefPtr<Gtk::Builder> _bldr );
	void connect_toolbar_signals ( void );
	bool on_timer_fired ( void );
	void on_skip_clicked ( void );
	void on_pause_clicked ( void );
			
	virtual void connect_signals ( void ) = 0;
	virtual void on_window_closed ( void ) = 0;
	virtual void update_window ( void ) = 0;
	virtual void on_risposta ( char tasto = -1 ) = 0;
	virtual void pause_test ( void ) = 0;
	virtual void continue_test ( void ) = 0;
	virtual void next_question ( void ) = 0;
	virtual bool show_result ( void ) = 0;

private:

};

inline TestEngine::
~TestEngine ()
{
	if ( _random )
		delete _random;
}

#endif // _TESTENGINE_H_
